package com.lzh.shijicloudstack.common;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * @author luzhiheng
 * @date 2023-11-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@MappedSuperclass
public class BaseEntity implements Serializable {

    /**
     * 主键ID
     */
    @Id
    @Column(name = "id", columnDefinition = "bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID'", nullable = false)
    private Long id;

    /**
     * 创建时间
     */
    @Column(name = "create_time", columnDefinition = "datetime COMMENT '创建时间'")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time", columnDefinition = "datetime COMMENT '更新时间'")
    @TableField(fill = FieldFill.UPDATE)
    private Date updateTime;

    /**
     * 更新人
     */
    @Column(name = "create_name", columnDefinition = "varchar(255) COMMENT '创建人'")
    @TableField(fill = FieldFill.INSERT)
    private String createName;

    /**
     * 更新人
     */
    @Column(name = "update_name", columnDefinition = "varchar(255) COMMENT '更新人'")
    @TableField(fill = FieldFill.UPDATE)
    private String updateName;

    /**
     * 逻辑删除（0代表未删除，1代表已删除）
     */
    @Column(name = "del_flag", columnDefinition = "int DEFAULT '0' COMMENT '逻辑删除（0代表未删除，1代表已删除）'")
    @TableLogic
    private Integer delFlag = 0;
}
